<?php
!function_exists('readover') && exit('Forbidden');
class PW_ImageElement {
	var $imageService;
	function PW_ImageElement() {
		$this->__construct();
	}
	function __construct() {
		$this->imageService = House::loadClass('houseimage'); /* @var $this->imageService PW_HouseImage */
	}
	
	function housePic($round='',$num=0,$hid=0) {
		$this->imageService->setPerpage($num);
		$round = $this->_picRoundInit($round);
		$images = $this->imageService->getImages($hid,$round);
		$temp = array();
		foreach ($images as $key=>$value) {
			$temp[] = $this->_dataInit($value);
		}
		return $temp;
	}
	
	function _picRoundInit($round) {
		$round = (int) $round;
		if (!$round) return '';
		$imageTypeService = House::loadClass('houseimagetype'); /* @var $imageTypeService PW_HouseImageType */
		$imageType = $imageTypeService->getType($round);
		if ($imageType['sub']) return $round;
		$secendTypes = $imageTypeService->getSecendTypesById($round);
		$searchTypeid = array_keys($secendTypes);
		$searchTypeid[] = $round;
		
		return $searchTypeid;
	}
	
	function _dataInit($data) {
		$temp = array();
		$temp['url'] 	= $data['url'];
		$temp['title'] 	= $data['descrip'];
		$temp['value'] 	= $data['hits'];
		$temp['image']	= $data['path'];
		$temp['mini']	= $data['mini'];
		$temp['uploadtime']	= $data['uploadtime'];
		$temp['addition'] = array();
		return $temp;
	}
}
?>